package com.sline.stream;

import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;

public class Demo2_FileOutputStream {
    public static void main(String[] args) throws IOException {
//        demo1();


    }

    private static void demo1() throws IOException {
        /*
        * 当向一个已经有内容的文件中写入数据时会将以前的数据清空后重新写入
        * 如果不想清空以前的数据, 则在创建FileOutputStream的时候第二个参数传入true*/
        FileOutputStream fos = new FileOutputStream("abcd.txt");

        fos.write(97);
        fos.write(98);
        fos.write(99);

        fos.close();

        FileOutputStream fos1 = new FileOutputStream("abcd.txt");

        fos1.write(100);

        fos1.close();

        FileOutputStream fos2 = new FileOutputStream("abcd.txt", true);
        fos2.write(97);
        fos2.write(98);
        fos2.write(99);
        fos2.close();
    }
}
